
from apps.common.base.serializers import *
from apps.pay.financeForLessee.models import *

class FinanceForLesseeBaseSerializer(BaseSerializer):

    class Meta:
        model = FinanceForLessee
        fields = "__all__"

class FinanceForLesseeModelSerializer(BaseSerializer):


    dateValueStr = serializers.SerializerMethodField()
    def get_dateValueStr(self, obj):
        if obj.dateCycle == 'year':
            return obj.dateValue.strftime('%Y')
        elif obj.dateCycle == 'month':
            return obj.dateValue.strftime('%Y-%m')
        elif obj.dateCycle == 'day':
            return obj.dateValue.strftime('%Y-%m-%d')
        
    class Meta:
        model = FinanceForLessee
        fields = "__all__"